<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initDatabase(){
        
        require_once 'configs/config.php';
        $db = Zend_Db::factory( Config::getTypeMsql()  , Config::getDatabase() );
        Zend_Db_Table::setDefaultAdapter($db);
        Zend_Registry::set("db", $db);
    }
    
    protected function _initLayout(){
       
        $front = Zend_Controller_Front::getInstance();
        $uri = $_SERVER['REQUEST_URI'];
        $uri = explode('/', $uri);
        switch ($uri[1]){
            case "admincp":
            {
                
                $layoutpath=APPLICATION_PATH.'/../public/templates/admincp/default';
                $options=array('layout'=>'index',
                    'layoutPath'=>$layoutpath);
                Zend_Layout::startMvc($options);
                $cf = new  Zend_Config_Ini(APPLICATION_PATH.'/../public/templates/admincp/default/install.ini','templates');
                $view = Zend_Layout::getMvcInstance()->getView();
                $view->headMeta()->appendHttpEquiv('Content-Type','text/html;charset=UTF-8');
                //$view->headTitle()->headTitle('Admin Control');
                $view->headLink()->appendStylesheet($front->getBaseUrl().'/templates/admincp/default/'.$cf->templates->dircss .'/'.$cf->templates->filecss);
            }
            break;
            default:
            {
                $layoutpath=APPLICATION_PATH.'/../public/templates/front/default';
                $options=array('layout'=>'index',
                    'layoutPath'=>$layoutpath);
                Zend_Layout::startMvc($options);
                $cf = new  Zend_Config_Ini(APPLICATION_PATH.'/../public/templates/front/default/install.ini','templates');
                $view = Zend_Layout::getMvcInstance()->getView();
                $view->headMeta()->appendHttpEquiv('Content-Type','text/html;charset=UTF-8');                
                $view->headLink()->appendStylesheet($front->getBaseUrl().'/templates/front/default/'.$cf->templates->dircss .'/'.$cf->templates->filecss);
                $view->headScript()->appendFile($front->getBaseUrl().'/templates/front/default/'.$cf->templates->dirjs .'/'.$cf->templates->filescript);
            }
            break;
        }
                
    }

}

